package com.qiusuo0226.core.pojo.dto;

import com.qiusuo0226.platform.annotation.valid.ValidType;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 字典项新增 业务模型
 * @author qiusuo
 * @date 2023/7/23 21:47
 */
@Data
public class DictionaryAddDTO {

    /**
     * 字典组名
     */
    @NotBlank(message = "字典组名不能为空")
    @Length(min = 1, max = 100, message = "字典组名长度在1~100之间")
    private String groupName;

    /**
     * 字典组编码
     */
    @NotBlank(message = "字典组编码不能为空")
    @Length(min = 1, max = 100, message = "字典组编码长度在1~100之间")
    private String groupCode;

    /**
     * 字典值集合
     */
    @NotNull(message = "字典值配置不能为空")
    @NotEmpty(message = "字典值配置不能为空")
    private List<Dictionary> dictionaries;

    /**
     * 新增类型
     */
    @ValidType(types = {"1", "2"}, message = "新增类型错误")
    @NotBlank(message = "新增类型不能为空")
    private String type;

    /**
     * 字典值内部类
     */
    @Data
    public static class Dictionary {
        /**
         * 字典名
         */
        @Length(min = 1, max = 100, message = "字典名长度在1~100之间")
        private String dictionaryName;
        /**
         * 字典编码
         */
        @Length(min = 1, max = 100, message = "字典编码长度在1~100之间")
        private String dictionaryCode;

        /**
         * 排序
         */
        private Integer sort;

    }
}
